package chapter4.No4_1_使用reentrantLock类.demo13;

/**
 * *：
 *    方法hasQueuedThread(Thread thread)、hasQueuedThreads()和hasWaiters()
 *
 *      hasQueuedThread(Thread thread)：查询该线程是否在获取锁定
 *      hasQueuedThreads()：查询是否有线程正在等待获取此锁定
 * Created by Administrator on 2016/11/22.
 */
public class Main {
    public static void main(String[] args) throws InterruptedException {
        final ServiceClass sc = new ServiceClass();
        Runnable runnable = new Runnable(){
            public void run() {
                sc.methodA();
            }
        };
        Thread a = new Thread(runnable);
        a.start();
        Thread.sleep(500);
        Thread b = new Thread(runnable);
        b.start();
        Thread.sleep(500);
        System.out.println(sc.lock.hasQueuedThread(a));
        System.out.println(sc.lock.hasQueuedThread(b));
        System.out.println(sc.lock.hasQueuedThreads());
    }
}
